package tree;


import tree.data.TreeNode;

/**
 * 对称二叉树
 *
 * https://leetcode.cn/problems/symmetric-tree/?envType=study-plan-v2&envId=top-100-liked
 */
public class IsSymmetric {




    public boolean check(TreeNode l,TreeNode r){
        if (l==null&&r==null){
            return true;
        }
        if (l == null || r == null){
            return false;
        }
        return l.val==r.val&&check(l.left,r.right)&&check(l.right,r.left);
    }

    public boolean isSymmetric(TreeNode root) {
        if (root==null){
            return true;
        }
        return check(root.left,root.right);
    }
}
